/*
 * Copyright (C) 2021-2024, 5DPLAY Game Studio
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.play5d.game.bvn.utils {
import flash.display.DisplayObject;
import flash.display.Sprite;

public class DebugSprite extends Sprite {
    include '../../../../../../include/_INCLUDE_.as';


    public function DebugSprite(color:uint, target:DisplayObject = null) {

        var w:Number = target.width < 30 ? 30 : target.width;
        var h:Number = target.height < 30 ? 30 : target.height;

        this.x = target.x;
        this.y = target.y;
        this.graphics.beginFill(color, 1);
        this.graphics.drawRect(0, 0, w, h);

        this.target = target;
    }
    public var target:DisplayObject;

    public function applySet():void {
        target.x = x;
        target.y = y;

        trace('================== debug apply set ========================');
        trace('x:', target.x, 'y:', target.y, 'width:', target.width, 'height:', target.height);
        trace('-----------------------------------------------------------');
    }

    public function destory():void {
        target = null;
        try {
            this.parent.removeChild(this);
        }
        catch (e:Error) {
        }
    }

}

}
